package com.ruoyi.account.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.RequiresPermissions;
import com.ruoyi.account.domain.Account;
import com.ruoyi.account.service.IAccountService;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.page.TableDataInfo;

/**
 * 存储账套基础信息及所属公司税务相关信息Contro
 * 
 * @author ruoyi
 * @date 2025-02-25
 */
@RestController
@RequestMapping("/account")
public class AccountController extends BaseController
{
    //111
    @Autowired
    private IAccountService accountService;

    /**
     * 查询存储账套基础信息及所属公司税务相关信息列表
     */
    @RequiresPermissions("account:account:list")
    @GetMapping("/list")
    public TableDataInfo list(Account account)
    {
        startPage();
        List<Account> list = accountService.selectAccountList(account);
        return getDataTable(list);
    }

    /**
     * 导出存储账套基础信息及所属公司税务相关信息列表
     */
    @RequiresPermissions("account:account:export")
    @Log(title = "存储账套基础信息及所属公司税务相关信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, Account account)
    {
        List<Account> list = accountService.selectAccountList(account);
        ExcelUtil<Account> util = new ExcelUtil<Account>(Account.class);
        util.exportExcel(response, list, "存储账套基础信息及所属公司税务相关信息数据");
    }



    /**
     * 新增存储账套基础信息及所属公司税务相关信息
     */
    @RequiresPermissions("account:account:add")
    @Log(title = "存储账套基础信息及所属公司税务相关信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@Validated @RequestBody Account account)
    {
        return toAjax(accountService.insertAccount(account));
    }

    /**
     * 修改存储账套基础信息及所属公司税务相关信息
     */
    @RequiresPermissions("account:account:edit")
    @Log(title = "存储账套基础信息及所属公司税务相关信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Account account)
    {
        return toAjax(accountService.updateAccount(account));
    }

    /**
     * 删除存储账套基础信息及所属公司税务相关信息
     */
    @RequiresPermissions("account:account:remove")
    @Log(title = "存储账套基础信息及所属公司税务相关信息", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {

        return toAjax(accountService.deleteAccountByIds(ids));
    }

    /**
     * 获取存储账套基础信息及所属公司税务相关信息详细信息
     */
    @RequiresPermissions("account:account:query")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(accountService.selectAccountIsId(id));
    }

//    /*
//     * @description:
//     * @author: Mr.che
//     * @date: 2025/2/28 18:40
//     * @param: accountSetId
//     * @return: AjaxResult
//     修改的回显
//     **/
//    @RequiresPermissions("account:account:query")
//    @GetMapping("/account/{accountId}")
//    public AjaxResult getAccountById(@PathVariable("accountId") String accountId)
//    {
//        return success(accountService.selectAccountById(accountId));
//    }

}
